package com.gluck.cases.core.modal.assemble;

import com.gluck.cases.common.utils.utils.TimeUtils;
import com.gluck.cases.core.modal.dto.CasesTestsDTO;
import com.gluck.cases.core.modal.entity.CasesTests;

import java.time.LocalDateTime;
import java.util.Objects;

/**
 * @ClassName CasesTestsAssemble
 * @Desc CasesTests 组装类
 * @Author shiyongzhe
 * @Date 2022/6/3 - 3:00 下午
 **/
public class CasesTestsAssemble {

    public static CasesTestsDTO CasesTestConvertDTO(CasesTests tests){
        CasesTestsDTO dto = new CasesTestsDTO();
        dto.setCreatedBy(tests.getCreatedBy());
        dto.setCasesApi(tests.getCasesApi());
        dto.setDataInfo(tests.getDataInfo());
        dto.setGroupId(tests.getGroupId());
        dto.setCreatedAt(TimeUtils.format(tests.getCreatedAt(), TimeUtils.DATETIME_FORMATTER));
        return dto;
    }

    public static CasesTests CasesTestDTOConvertCasesTest(CasesTestsDTO dto){
        CasesTests test = new CasesTests();
        if(!Objects.isNull(dto.getId())){
            test.setId(dto.getId());
        }
        test.setCreatedBy(dto.getCreatedBy());
        test.setCasesApi(dto.getCasesApi());
        test.setDataInfo(dto.getDataInfo());
        test.setGroupId(dto.getGroupId());
        test.setCreatedAt(LocalDateTime.now());
//        test.setUpdatedAt(LocalDateTime.now());
        test.setCreatedBy(dto.getCreatedBy());
        return test;
    }


}
